package com.ydgk.ajax;

import com.alibaba.fastjson.JSON;
import com.ydgk.bean.Teacher;
import com.ydgk.dao.TeacherDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "TeacherShowAjaxServlet", urlPatterns = "/TeacherShowAjaxServlet.action")
public class TeacherShowAjaxServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        TeacherDao teacherDao = new TeacherDao();
        List<Teacher> teacherList = teacherDao.findAll();
        response.getWriter().print(JSON.toJSONString(teacherList));
    }

}
